Java

Request header is too large

2022/02/18 01:15 3725 次阅读王梓
★ 打赏
✸ ✸ ✸

背景

个别用户反馈无法登录

调查

查看日志找到一条错误记录:

java.lang.IllegalArgumentException: Request header is too large

定位原因

一个request中 总的header超过了8kb,其中jwt token就超过了6kb,加上其他杂七杂八的header超过了8kb.

tomcat 8版本 默认不允许超过 8kb

tomcat 5版本 默认不允许超过 4kb

临时解决

在报错的服务上增加配置 application.xml

server:
    ....
    max-http-header-size:16KB
    ....

最终解决

减少jwt token拼接的无用数据量,减少request header 大小.

Background

Feedback from a few users feedback can not logon

Log Error

java.lang.IllegalArgumentException: Request header is too large

Positioning reason

The JWT token in the header exceeds 6kb, and the total request header exceeds 8kb. The default value allowed in Tomcat embedded in Spring Boot is that the Request header cannot exceed 8kb.

tomcat 8 < 8kb

tomcat 5 < 4kb

Temporary solution

Set max-http-header-size to 16K in the recived service

Final solution

Reduce the amount of useless data for JWT token stitching and reduce the size of request Headers.

✸ ✸ ✸

📜 版权声明

本文作者:王梓 | 原文链接:https://www.bthlt.com/note/14218872-JavaRequest header is too large

出处:葫芦的运维日志 | 转载请注明出处并保留原文链接

📜 留言板

留言提交后需管理员审核通过才会显示